VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Adds an \ If needed, quit the \ when needed too...

by Jafo C - Null (3 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 1st April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Adds an "\" If needed, quit the "\" when needed too...

Rate Adds an \ If needed, quit the \ when needed too...



'
'FuncMode.- (0 or 1), if you set 1 comparePath will add an "\", if you set to
'0 ComparePath will remove the "\".
'
'You can put a FileName too.
'EX.
'
'ComparePath "C:\windows\system",1,"Kernel32.dll"
'Result Will Be: C:\windows\system\Kernel32.dll
'
'DO NOT USE A file name With FuncMode= 0
'--------------------------
Function ComparePath(ByVal strPathName As String, ByVal funcMode As Integer, Optional ByVal strFilename As String) As String

Dim aux As Integer

If funcMode = 1 Then
    If Right(Trim(strPathName), Len("\")) <> "\" Then
        ComparePath = Trim$(RTrim$(strPathName) & "\" & Trim$(strFilename))
    Else
        ComparePath = Trim$(RTrim$(strPathName) & Trim$(strFilename))
    End If
Else
    If strFilename <> "" Then
        Err.Raise 1, , "Function can't use mode 0 with a file name."
        Exit Function
    End If
    
    If Right(Trim(strPathName), Len("\")) <> "\" Then
        ComparePath = Trim$(RTrim$(strPathName))
    Else
        aux = Len(strPathName)
        ComparePath = Trim$(RTrim$(Left$(strPathName, aux - 1)))
    End If
End If
End Function

Download this snippet    Add to My Saved Code

Adds an \ If needed, quit the \ when needed too... Comments

No comments have been posted about Adds an \ If needed, quit the \ when needed too.... Why not be the first to post a comment about Adds an \ If needed, quit the \ when needed too....

Post your comment

Subject:
Message:
0/1000 characters